﻿namespace ACCOUNTING
{
    using ACCOUNTING.LVY.Business;
    using ACCOUNTING.My.Resources;
    using C1.Win.C1BarCode;
    using Microsoft.VisualBasic;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Imaging;
    using System.IO;
    using System.Runtime.CompilerServices;
    using System.Windows.Forms;

    [DesignerGenerated]
    public class Frm_InHoaDonTuIn : Form
    {
        private static List<WeakReference> __ENCList = new List<WeakReference>();
        [AccessedThroughProperty("BarCodeHD")]
        private C1.Win.C1BarCode.C1BarCode _BarCodeHD;
        [AccessedThroughProperty("btnXemTrangIn")]
        private Button _btnXemTrangIn;
        [AccessedThroughProperty("CboKiHieu")]
        private ComboBox _CboKiHieu;
        [AccessedThroughProperty("CboMau")]
        private ComboBox _CboMau;
        [AccessedThroughProperty("CmdDTThue")]
        private Button _CmdDTThue;
        [AccessedThroughProperty("CmdIn")]
        private Button _CmdIn;
        [AccessedThroughProperty("GrpHoaDon")]
        private GroupBox _GrpHoaDon;
        [AccessedThroughProperty("Label1")]
        private Label _Label1;
        [AccessedThroughProperty("Label12")]
        private Label _Label12;
        [AccessedThroughProperty("Label14")]
        private Label _Label14;
        [AccessedThroughProperty("Label15")]
        private Label _Label15;
        [AccessedThroughProperty("Label2")]
        private Label _Label2;
        [AccessedThroughProperty("Label30")]
        private Label _Label30;
        [AccessedThroughProperty("Label8")]
        private Label _Label8;
        [AccessedThroughProperty("txtDiaChiThue")]
        private TextBox _txtDiaChiThue;
        [AccessedThroughProperty("TxtMaSoThue")]
        private TextBox _TxtMaSoThue;
        [AccessedThroughProperty("TxtNgayHoaDon")]
        private DateTimePicker _TxtNgayHoaDon;
        [AccessedThroughProperty("TxtSoHoaDon")]
        private TextBox _TxtSoHoaDon;
        [AccessedThroughProperty("TxtTenDoiTuongThue")]
        private TextBox _TxtTenDoiTuongThue;
        private byte[] arrImage;
        public string cFrmKhoa;
        public string cFrmLoaiBanHang;
        private IContainer components;
        private bool mAllowAdd;
        private bool mAllowDel;
        private bool mAllowEdit;
        private bool mAllowView;
        private bool mEnabledControl;
        public object objFrmCall;
        private clsXuatKho objHD;
        private clsMauHoaDon objMHD;
        private DataTable pData;
        private string pLoaiHoaDonIn;
        private string pTenRpt;
        private string strKiHieu;
        private string strMau;
        private string strSoHD;

        public Frm_InHoaDonTuIn()
        {
            base.FormClosing += new FormClosingEventHandler(this.Frm_InHoaDonTuIn_FormClosing);
            base.Load += new EventHandler(this.Frm_InHoaDonTuIn_Load);
            List<WeakReference> list = __ENCList;
            lock (list)
            {
                __ENCList.Add(new WeakReference(this));
            }
            this.mEnabledControl = true;
            this.cFrmKhoa = "";
            this.objHD = new clsXuatKho();
            this.objMHD = new clsMauHoaDon();
            this.pData = new DataTable();
            this.pLoaiHoaDonIn = "";
            this.pTenRpt = "";
            this.cFrmLoaiBanHang = "";
            this.arrImage = null;
            this.InitializeComponent();
        }

        private void btnXemTrangIn_Click(object sender, EventArgs e)
        {
            if (this.objHD.Load(this.cFrmKhoa) && this.CheckIvalid())
            {
                this.GetBarCode();
                this.arrImage = this.GetImageByteArray();
                this.strMau = this.CboMau.Text.Trim();
                this.strKiHieu = this.CboKiHieu.Text.Trim();
                if (this.cFrmLoaiBanHang == "XB")
                {
                    if (this.pLoaiHoaDonIn == "GTGT")
                    {
                        ReportModule.PrintHoaDonVAT(this.arrImage, this.cFrmKhoa, this.pTenRpt, "Preview", "'" + Conversions.ToString(this.TxtNgayHoaDon.Value) + "' as NgayHoaDon,'" + this.strMau + "' as MauHoaDon,'" + this.strKiHieu + "' as SoSeri,'" + this.TxtSoHoaDon.Text.Trim() + "' as SoHoaDon, UPPER(N'" + this.TxtTenDoiTuongThue.Text + "') as KhachHang,'" + this.TxtMaSoThue.Text + "' as MaSoThue ,");
                    }
                    else if (this.pLoaiHoaDonIn == "HDBH")
                    {
                        ReportModule.PrintHoaDonHDBH(this.arrImage, this.cFrmKhoa, this.pTenRpt, "Preview", "'" + Conversions.ToString(this.TxtNgayHoaDon.Value) + "' as NgayHoaDon,'" + this.strMau + "' as MauHoaDon,'" + this.strKiHieu + "' as SoSeri,'" + this.TxtSoHoaDon.Text.Trim() + "' as SoHoaDon, UPPER(N'" + this.TxtTenDoiTuongThue.Text + "') as KhachHang,'" + this.TxtMaSoThue.Text + "' as MaSoThue ,");
                    }
                }
                else if (this.cFrmLoaiBanHang == "TH")
                {
                    if (this.pLoaiHoaDonIn == "GTGT")
                    {
                        ReportModule.PrintHoaDonVATTraHang(this.arrImage, this.cFrmKhoa, this.pTenRpt, "Preview", "'" + Conversions.ToString(this.TxtNgayHoaDon.Value) + "' as NgayHoaDon,'" + this.strMau + "' as MauHoaDon,'" + this.strKiHieu + "' as SoSeri,'" + this.TxtSoHoaDon.Text.Trim() + "' as SoHoaDon, UPPER(N'" + this.TxtTenDoiTuongThue.Text + "') as KhachHang,'" + this.TxtMaSoThue.Text + "' as MaSoThue ,");
                    }
                    else if (this.pLoaiHoaDonIn == "HDBH")
                    {
                        ReportModule.PrintHoaDonHDBHTraHang(this.arrImage, this.cFrmKhoa, this.pTenRpt, "Preview", "'" + Conversions.ToString(this.TxtNgayHoaDon.Value) + "' as NgayHoaDon,'" + this.strMau + "' as MauHoaDon,'" + this.strKiHieu + "' as SoSeri,'" + this.TxtSoHoaDon.Text.Trim() + "' as SoHoaDon, UPPER(N'" + this.TxtTenDoiTuongThue.Text + "') as KhachHang,'" + this.TxtMaSoThue.Text + "' as MaSoThue ,");
                    }
                }
                else if (this.pLoaiHoaDonIn == "GTGT")
                {
                    ReportModule.PrintHoaDonVATDichVu(this.arrImage, this.cFrmKhoa, this.pTenRpt, "Preview", "'" + Conversions.ToString(this.TxtNgayHoaDon.Value) + "' as NgayHoaDon,'" + this.strMau + "' as MauHoaDon,'" + this.strKiHieu + "' as SoSeri,'" + this.TxtSoHoaDon.Text.Trim() + "' as SoHoaDon, UPPER(N'" + this.TxtTenDoiTuongThue.Text + "') as KhachHang,'" + this.TxtMaSoThue.Text + "' as MaSoThue ,");
                }
                else if (this.pLoaiHoaDonIn == "HDBH")
                {
                    ReportModule.PrintHoaDonHDBHDichVu(this.arrImage, this.cFrmKhoa, this.pTenRpt, "Preview", "'" + Conversions.ToString(this.TxtNgayHoaDon.Value) + "' as NgayHoaDon,'" + this.strMau + "' as MauHoaDon,'" + this.strKiHieu + "' as SoSeri,'" + this.TxtSoHoaDon.Text.Trim() + "' as SoHoaDon, UPPER(N'" + this.TxtTenDoiTuongThue.Text + "') as KhachHang,'" + this.TxtMaSoThue.Text + "' as MaSoThue ,");
                }
            }
        }

        public void CapSoHD(int Preview)
        {
            if (this.mEnabledControl && ((this.CboMau.Text.Trim() != "") & (this.CboKiHieu.Text.Trim() != "")))
            {
                this.strMau = this.CboMau.Text.Trim();
                this.strKiHieu = this.CboKiHieu.Text.Trim();
                this.TxtSoHoaDon.Text = modGeneral.CapSoHoaDon(this.strMau, this.strKiHieu, Preview);
            }
        }

        private void CboKiHieu_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.GetBarCode();
            if (this.CboKiHieu.SelectedIndex > 0)
            {
                this.TxtSoHoaDon.Focus();
                this.CapSoHD(0);
            }
            else
            {
                this.TxtSoHoaDon.Text = "";
            }
        }

        private void CboMau_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.GetBarCode();
            this.CboKiHieu.Focus();
            if (this.CboMau.SelectedIndex >= 0)
            {
                this.objMHD.Load(this.CboMau.Text);
                this.pLoaiHoaDonIn = this.objMHD.KhoaLoaiHoaDonIn.Trim();
                this.pTenRpt = this.objMHD.TenReport.Trim();
                BuildComboModule.BuildCombo(this.CboKiHieu, modGeneral.ListDanhMuc.SoKiHieu, true, "MauHoaDon = '" + this.CboMau.Text + "' AND Isnull(TuSo,0) <> 0", "");
            }
            else
            {
                this.CboKiHieu.DataSource = this.pData;
                this.CboKiHieu.DisplayMember = "Ten";
                this.CboKiHieu.ValueMember = "Ma";
            }
        }

        public bool CheckIvalid()
        {
            if (LVYModule.ReturnIfNull(this.CboMau.Text, "", modGeneral.TypeOfValue.Nothing).ToString().Trim() == "")
            {
                LVYModule.ShowWarning(modGeneral.Tranlated("Bạn phải chọn mẫu h\x00f3a đơn!", ""));
                this.CboMau.Focus();
                return false;
            }
            if (LVYModule.ReturnIfNull(this.CboKiHieu.Text, "", modGeneral.TypeOfValue.Nothing).ToString().Trim() == "")
            {
                LVYModule.ShowWarning(modGeneral.Tranlated("Bạn phải nhập số seri!", ""));
                this.CboMau.Focus();
                return false;
            }
            if (LVYModule.ReturnIfNull(this.TxtSoHoaDon.Text, "", modGeneral.TypeOfValue.Nothing).ToString().Trim() == "")
            {
                LVYModule.ShowWarning(modGeneral.Tranlated("Chưa c\x00f3 số h\x00f3a đơn!", ""));
                this.CboMau.Focus();
                return false;
            }
            if (LVYModule.ReturnIfNull(this.TxtNgayHoaDon.Value, "", modGeneral.TypeOfValue.Nothing).ToString().Trim() == "")
            {
                LVYModule.ShowWarning(modGeneral.Tranlated("Bạn phải chọn ng\x00e0y h\x00f3a đơn!", ""));
                this.TxtNgayHoaDon.Focus();
                return false;
            }
            this.objHD.Load(this.cFrmKhoa);
            if ((this.objHD.DaIn == 0) && !this.objMHD.CheckNgayThang(this.cFrmKhoa, LVYModule.Date2Char(Conversions.ToString(this.TxtNgayHoaDon.Value)), this.CboMau.Text, this.CboKiHieu.Text, this.TxtSoHoaDon.Text))
            {
                this.TxtNgayHoaDon.Focus();
                return false;
            }
            return true;
        }

        private void CmdDTThue_Click(object sender, EventArgs e)
        {
            string str;
            string expression = "";
            if (this.mEnabledControl)
            {
                str = "";
            }
            else
            {
                str = "VIEW";
            }
            expression = Conversions.ToString(SearchModule.SearchDoiTuongThue(this.TxtTenDoiTuongThue.Text, this.TxtMaSoThue.Text, this.txtDiaChiThue.Text, str));
            if (expression != "")
            {
                object instance = Strings.Split(expression, "|", -1, CompareMethod.Binary);
                this.TxtTenDoiTuongThue.Text = Conversions.ToString(NewLateBinding.LateIndexGet(instance, new object[] { 0 }, null));
                this.TxtMaSoThue.Text = Conversions.ToString(NewLateBinding.LateIndexGet(instance, new object[] { 1 }, null));
                this.txtDiaChiThue.Text = Conversions.ToString(NewLateBinding.LateIndexGet(instance, new object[] { 2 }, null));
            }
        }

        private void CmdIn_Click(object sender, EventArgs e)
        {
            if (this.objHD.Load(this.cFrmKhoa) && this.CheckIvalid())
            {
                string barCode = this.GetBarCode();
                this.arrImage = this.GetImageByteArray();
                if (Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectEqual(LVYModule.ReturnIfNull(this.objHD.DaIn, 0, modGeneral.TypeOfValue.Nothing), 1, false))
                {
                    if (this.cFrmLoaiBanHang == "XB")
                    {
                        if (MessageBox.Show("H\x00f3a đơn đ\x00e3 in bản ch\x00ednh thức rồi! Đồng \x00fd in bản sao ?", "DRAGON2 - Thong Bao", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                        {
                            if (this.pLoaiHoaDonIn == "GTGT")
                            {
                                ReportModule.PrintHoaDonVAT(this.arrImage, this.cFrmKhoa, this.pTenRpt, "Copy", "");
                            }
                            else if (this.pLoaiHoaDonIn == "HDBH")
                            {
                                ReportModule.PrintHoaDonHDBH(this.arrImage, this.cFrmKhoa, this.pTenRpt, "Copy", "");
                            }
                        }
                    }
                    else if (this.cFrmLoaiBanHang == "TH")
                    {
                        if (MessageBox.Show("H\x00f3a đơn đ\x00e3 in bản ch\x00ednh thức rồi! Đồng \x00fd in bản sao ?", "DRAGON2 - Thong Bao", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                        {
                            if (this.pLoaiHoaDonIn == "GTGT")
                            {
                                ReportModule.PrintHoaDonVATTraHang(this.arrImage, this.cFrmKhoa, this.pTenRpt, "Copy", "");
                            }
                            else if (this.pLoaiHoaDonIn == "HDBH")
                            {
                                ReportModule.PrintHoaDonHDBHTraHang(this.arrImage, this.cFrmKhoa, this.pTenRpt, "Copy", "");
                            }
                        }
                    }
                    else if (MessageBox.Show("H\x00f3a đơn đ\x00e3 in bản ch\x00ednh thức rồi! Đồng \x00fd in bản sao ?", "DRAGON2 - Thong Bao", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                    {
                        if (this.pLoaiHoaDonIn == "GTGT")
                        {
                            ReportModule.PrintHoaDonVATDichVu(this.arrImage, this.cFrmKhoa, this.pTenRpt, "Copy", "");
                        }
                        else if (this.pLoaiHoaDonIn == "HDBH")
                        {
                            ReportModule.PrintHoaDonHDBHDichVu(this.arrImage, this.cFrmKhoa, this.pTenRpt, "Copy", "");
                        }
                    }
                }
                else if (MessageBox.Show("H\x00f3a đơn n\x00e0y chỉ c\x00f3 thể in bản ch\x00ednh thức một lần! Đồng \x00fd ?", "DRAGON2 - Thong Bao", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                {
                    this.CapSoHD(1);
                    this.strMau = this.CboMau.Text.Trim();
                    this.strKiHieu = this.CboKiHieu.Text.Trim();
                    clsXuatKho objHD = this.objHD;
                    objHD.MauHoaDon = this.strMau;
                    objHD.SoHoaDon = this.TxtSoHoaDon.Text.Trim();
                    objHD.SoSeri = this.strKiHieu;
                    objHD.NgayHoaDon = LVYModule.Date2Char(this.TxtNgayHoaDon.Text);
                    objHD.TenDoiTuongThue = this.TxtTenDoiTuongThue.Text;
                    objHD.MaSoThue = this.TxtMaSoThue.Text.Trim();
                    objHD.DienGiai = Conversions.ToString(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(LVYModule.ReturnIfNull(objHD.DienGiai, "", modGeneral.TypeOfValue.Nothing), "  HD số : "), this.TxtSoHoaDon.Text.Trim()));
                    objHD.BarCode = this.objMHD.MD5(barCode);
                    objHD = null;
                    this.objHD.Update();
                    this.GrpHoaDon.Enabled = false;
                    if (this.cFrmLoaiBanHang == "XB")
                    {
                        if (this.pLoaiHoaDonIn == "GTGT")
                        {
                            ReportModule.PrintHoaDonVAT(this.arrImage, this.cFrmKhoa, this.pTenRpt, "Print", "");
                        }
                        else if (this.pLoaiHoaDonIn == "HDBH")
                        {
                            ReportModule.PrintHoaDonHDBH(this.arrImage, this.cFrmKhoa, this.pTenRpt, "Print", "");
                        }
                    }
                    else if (this.cFrmLoaiBanHang == "TH")
                    {
                        if (this.pLoaiHoaDonIn == "GTGT")
                        {
                            ReportModule.PrintHoaDonVATTraHang(this.arrImage, this.cFrmKhoa, this.pTenRpt, "Print", "");
                        }
                        else if (this.pLoaiHoaDonIn == "HDBH")
                        {
                            ReportModule.PrintHoaDonHDBHTraHang(this.arrImage, this.cFrmKhoa, this.pTenRpt, "Print", "");
                        }
                    }
                    else if (this.pLoaiHoaDonIn == "GTGT")
                    {
                        ReportModule.PrintHoaDonVATDichVu(this.arrImage, this.cFrmKhoa, this.pTenRpt, "Print", "");
                    }
                    else if (this.pLoaiHoaDonIn == "HDBH")
                    {
                        ReportModule.PrintHoaDonHDBHDichVu(this.arrImage, this.cFrmKhoa, this.pTenRpt, "Print", "");
                    }
                }
            }
        }

        [DebuggerNonUserCode]
        protected override void Dispose(bool disposing)
        {
            try
            {
                if (disposing && (this.components != null))
                {
                    this.components.Dispose();
                }
            }
            finally
            {
                base.Dispose(disposing);
            }
        }

        private void Frm_InHoaDonTuIn_FormClosing(object sender, FormClosingEventArgs e)
        {
            object[] arguments = new object[] { this.cFrmKhoa };
            bool[] copyBack = new bool[] { true };
            NewLateBinding.LateCall(this.objFrmCall, null, "ShowData", arguments, null, null, copyBack, true);
            if (copyBack[0])
            {
                this.cFrmKhoa = (string) Conversions.ChangeType(RuntimeHelpers.GetObjectValue(arguments[0]), typeof(string));
            }
        }

        private void Frm_InHoaDonTuIn_Load(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            LVYModule.GetUserRight(ref this.mAllowView, ref this.mAllowDel, ref this.mAllowEdit, ref this.mAllowAdd, Conversions.ToString(this.Tag), modGeneral.H_USERNAME);
            if (!this.mAllowView)
            {
                LVYModule.ShowWarning(modGeneral.Tranlated("Bạn kh\x00f4ng c\x00f3 quyền xem, li\x00ean hệ với người quản trị để biết th\x00eam chi tiết.", ""));
                this.Dispose();
            }
            else
            {
                this.Cursor = Cursors.Default;
                if (this.objHD.Load(this.cFrmKhoa))
                {
                    this.pData.Columns.Add("Ma", typeof(string));
                    this.pData.Columns.Add("Ten", typeof(string));
                    this.pData.Rows.Add(new object[] { "", "" });
                    BuildComboModule.BuildCombo(this.CboMau, modGeneral.ListDanhMuc.MauHoaDon, false, "KhoaLoaiHoaDonIn = '" + modGeneral.H_LOAIHOADONINMACDINH.Trim() + "'", "");
                    this.TxtSoHoaDon.ReadOnly = true;
                    try
                    {
                        if (Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectNotEqual(LVYModule.ReturnIfNull(this.objHD.DaIn, 0, modGeneral.TypeOfValue.Nothing), 0, false))
                        {
                            clsXuatKho objHD = this.objHD;
                            this.CboMau.Text = objHD.MauHoaDon.Trim();
                            this.TxtSoHoaDon.Text = objHD.SoHoaDon.Trim();
                            this.CboKiHieu.Text = objHD.SoSeri.Trim();
                            this.TxtNgayHoaDon.Text = LVYModule.Char2Date(objHD.NgayHoaDon).Trim();
                            this.TxtTenDoiTuongThue.Text = objHD.TenDoiTuongThue.Trim();
                            this.TxtMaSoThue.Text = objHD.MaSoThue.Trim();
                            objHD = null;
                            this.EnabledControl = false;
                        }
                        else
                        {
                            clsXuatKho kho2 = this.objHD;
                            this.CboMau.SelectedValue = modGeneral.H_MAUHOADONMACDINH;
                            this.TxtNgayHoaDon.Text = LVYModule.Char2Date(kho2.NgayHoaDon).Trim();
                            this.TxtTenDoiTuongThue.Text = kho2.TenDoiTuongThue.Trim();
                            this.TxtMaSoThue.Text = kho2.MaSoThue.Trim();
                            kho2 = null;
                        }
                        this.GrpHoaDon.Enabled = true;
                    }
                    catch (Exception exception1)
                    {
                        ProjectData.SetProjectError(exception1);
                        Exception exception = exception1;
                        ProjectData.ClearProjectError();
                    }
                    this.GetBarCode();
                }
            }
        }

        public string GetBarCode()
        {
            string str2 = this.objMHD.GetTextBarCode(Conversions.ToString(LVYModule.ReturnIfNull(this.CboMau.Text.Trim(), "", modGeneral.TypeOfValue.Nothing)), Conversions.ToString(LVYModule.ReturnIfNull(this.CboKiHieu.Text.Trim(), "", modGeneral.TypeOfValue.Nothing)), Conversions.ToString(LVYModule.ReturnIfNull(this.TxtSoHoaDon.Text.Trim(), "", modGeneral.TypeOfValue.Nothing)));
            this.BarCodeHD.Text = str2;
            return str2;
        }

        private static ImageCodecInfo GetEncoderInfo(ImageFormat format)
        {
            ImageCodecInfo[] imageEncoders = ImageCodecInfo.GetImageEncoders();
            for (int i = 0; i < imageEncoders.Length; i++)
            {
                if (imageEncoders[i].FormatID == format.Guid)
                {
                    return imageEncoders[i];
                }
            }
            return null;
        }

        public byte[] GetImageByteArray()
        {
            byte[] buffer;
            try
            {
                MemoryStream stream = new MemoryStream();
                Encoder quality = Encoder.Quality;
                ImageCodecInfo encoderInfo = GetEncoderInfo(ImageFormat.Png);
                EncoderParameters encoderParams = new EncoderParameters(1);
                EncoderParameter parameter = new EncoderParameter(quality, 0x4bL);
                encoderParams.Param[0] = parameter;
                this.BarCodeHD.GetImage(ImageFormat.Bmp).Save(stream, encoderInfo, encoderParams);
                buffer = stream.GetBuffer();
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                buffer = null;
                ProjectData.ClearProjectError();
                return buffer;
                ProjectData.ClearProjectError();
            }
            return buffer;
        }

        [DebuggerStepThrough]
        private void InitializeComponent()
        {
            this.GrpHoaDon = new GroupBox();
            this.CboKiHieu = new ComboBox();
            this.CboMau = new ComboBox();
            this.txtDiaChiThue = new TextBox();
            this.Label14 = new Label();
            this.TxtSoHoaDon = new TextBox();
            this.Label8 = new Label();
            this.CmdDTThue = new Button();
            this.TxtMaSoThue = new TextBox();
            this.Label1 = new Label();
            this.TxtTenDoiTuongThue = new TextBox();
            this.Label12 = new Label();
            this.Label15 = new Label();
            this.TxtNgayHoaDon = new DateTimePicker();
            this.Label30 = new Label();
            this.btnXemTrangIn = new Button();
            this.CmdIn = new Button();
            this.Label2 = new Label();
            this.BarCodeHD = new C1.Win.C1BarCode.C1BarCode();
            this.GrpHoaDon.SuspendLayout();
            this.SuspendLayout();
            this.GrpHoaDon.BackColor = Color.Transparent;
            this.GrpHoaDon.Controls.Add(this.CboKiHieu);
            this.GrpHoaDon.Controls.Add(this.CboMau);
            this.GrpHoaDon.Controls.Add(this.txtDiaChiThue);
            this.GrpHoaDon.Controls.Add(this.Label14);
            this.GrpHoaDon.Controls.Add(this.TxtSoHoaDon);
            this.GrpHoaDon.Controls.Add(this.Label8);
            this.GrpHoaDon.Controls.Add(this.CmdDTThue);
            this.GrpHoaDon.Controls.Add(this.TxtMaSoThue);
            this.GrpHoaDon.Controls.Add(this.Label1);
            this.GrpHoaDon.Controls.Add(this.TxtTenDoiTuongThue);
            this.GrpHoaDon.Controls.Add(this.Label12);
            this.GrpHoaDon.Controls.Add(this.Label15);
            this.GrpHoaDon.Controls.Add(this.TxtNgayHoaDon);
            this.GrpHoaDon.Controls.Add(this.Label30);
            Point point = new Point(12, 0x2d);
            this.GrpHoaDon.Location = point;
            this.GrpHoaDon.Name = "GrpHoaDon";
            Size size = new Size(0x1c3, 140);
            this.GrpHoaDon.Size = size;
            this.GrpHoaDon.TabIndex = 1;
            this.GrpHoaDon.TabStop = false;
            this.GrpHoaDon.Text = "Th\x00f4ng tin h\x00f3a đơn";
            this.CboKiHieu.FormattingEnabled = true;
            point = new Point(0x146, 0x1b);
            this.CboKiHieu.Location = point;
            this.CboKiHieu.Name = "CboKiHieu";
            size = new Size(0x6f, 0x15);
            this.CboKiHieu.Size = size;
            this.CboKiHieu.TabIndex = 2;
            this.CboMau.DropDownStyle = ComboBoxStyle.DropDownList;
            this.CboMau.FormattingEnabled = true;
            point = new Point(0x61, 0x1b);
            this.CboMau.Location = point;
            this.CboMau.Name = "CboMau";
            size = new Size(130, 0x15);
            this.CboMau.Size = size;
            this.CboMau.TabIndex = 0;
            point = new Point(0x5c, 0xd9);
            this.txtDiaChiThue.Location = point;
            this.txtDiaChiThue.Name = "txtDiaChiThue";
            this.txtDiaChiThue.ReadOnly = true;
            size = new Size(0x15c, 20);
            this.txtDiaChiThue.Size = size;
            this.txtDiaChiThue.TabIndex = 11;
            this.Label14.AutoSize = true;
            point = new Point(0x119, 30);
            this.Label14.Location = point;
            this.Label14.Name = "Label14";
            size = new Size(0x2a, 13);
            this.Label14.Size = size;
            this.Label14.TabIndex = 1;
            this.Label14.Text = "K\x00fd hiệu";
            this.TxtSoHoaDon.Font = new Font("Microsoft Sans Serif", 8.25f, FontStyle.Bold, GraphicsUnit.Point, 0);
            point = new Point(0x61, 0x36);
            this.TxtSoHoaDon.Location = point;
            this.TxtSoHoaDon.Name = "TxtSoHoaDon";
            size = new Size(130, 20);
            this.TxtSoHoaDon.Size = size;
            this.TxtSoHoaDon.TabIndex = 4;
            this.Label8.AutoSize = true;
            point = new Point(0x119, 0x39);
            this.Label8.Location = point;
            this.Label8.Name = "Label8";
            size = new Size(0x20, 13);
            this.Label8.Size = size;
            this.Label8.TabIndex = 5;
            this.Label8.Text = "Ng\x00e0y";
            this.CmdDTThue.BackgroundImageLayout = ImageLayout.Stretch;
            this.CmdDTThue.FlatStyle = FlatStyle.System;
            point = new Point(0x19e, 0x4e);
            this.CmdDTThue.Location = point;
            Padding padding = new Padding(0);
            this.CmdDTThue.Margin = padding;
            this.CmdDTThue.Name = "CmdDTThue";
            size = new Size(0x17, 0x16);
            this.CmdDTThue.Size = size;
            this.CmdDTThue.TabIndex = 9;
            this.CmdDTThue.Text = "...";
            this.CmdDTThue.UseVisualStyleBackColor = true;
            point = new Point(0x61, 0x67);
            this.TxtMaSoThue.Location = point;
            this.TxtMaSoThue.Name = "TxtMaSoThue";
            this.TxtMaSoThue.ReadOnly = true;
            size = new Size(340, 20);
            this.TxtMaSoThue.Size = size;
            this.TxtMaSoThue.TabIndex = 11;
            this.Label1.AutoSize = true;
            point = new Point(8, 30);
            this.Label1.Location = point;
            this.Label1.Name = "Label1";
            size = new Size(0x47, 13);
            this.Label1.Size = size;
            this.Label1.TabIndex = 0;
            this.Label1.Text = "Mẫu h\x00f3a đơn";
            point = new Point(0x61, 80);
            this.TxtTenDoiTuongThue.Location = point;
            this.TxtTenDoiTuongThue.Name = "TxtTenDoiTuongThue";
            this.TxtTenDoiTuongThue.ReadOnly = true;
            size = new Size(0x13a, 20);
            this.TxtTenDoiTuongThue.Size = size;
            this.TxtTenDoiTuongThue.TabIndex = 8;
            this.Label12.AutoSize = true;
            point = new Point(7, 0x39);
            this.Label12.Location = point;
            this.Label12.Name = "Label12";
            size = new Size(0x3f, 13);
            this.Label12.Size = size;
            this.Label12.TabIndex = 3;
            this.Label12.Text = "Số h\x00f3a đơn";
            this.Label15.AutoEllipsis = true;
            this.Label15.AutoSize = true;
            point = new Point(8, 0x53);
            this.Label15.Location = point;
            this.Label15.Name = "Label15";
            this.Label15.RightToLeft = RightToLeft.No;
            size = new Size(0x4d, 13);
            this.Label15.Size = size;
            this.Label15.TabIndex = 10;
            this.Label15.Text = "Đối tượng thuế";
            this.Label15.TextAlign = ContentAlignment.TopRight;
            this.TxtNgayHoaDon.Format = DateTimePickerFormat.Custom;
            point = new Point(0x146, 0x36);
            this.TxtNgayHoaDon.Location = point;
            this.TxtNgayHoaDon.Name = "TxtNgayHoaDon";
            size = new Size(0x6f, 20);
            this.TxtNgayHoaDon.Size = size;
            this.TxtNgayHoaDon.TabIndex = 6;
            this.Label30.AutoEllipsis = true;
            this.Label30.AutoSize = true;
            point = new Point(8, 0x6a);
            this.Label30.Location = point;
            this.Label30.Name = "Label30";
            this.Label30.RightToLeft = RightToLeft.No;
            size = new Size(30, 13);
            this.Label30.Size = size;
            this.Label30.TabIndex = 7;
            this.Label30.Text = "MST";
            this.Label30.TextAlign = ContentAlignment.TopRight;
            point = new Point(0x119, 0xbf);
            this.btnXemTrangIn.Location = point;
            this.btnXemTrangIn.Name = "btnXemTrangIn";
            size = new Size(0x52, 0x1b);
            this.btnXemTrangIn.Size = size;
            this.btnXemTrangIn.TabIndex = 2;
            this.btnXemTrangIn.Text = "Xem trang In";
            this.btnXemTrangIn.UseVisualStyleBackColor = true;
            point = new Point(0x171, 0xbf);
            this.CmdIn.Location = point;
            this.CmdIn.Name = "CmdIn";
            size = new Size(0x5f, 0x1b);
            this.CmdIn.Size = size;
            this.CmdIn.TabIndex = 3;
            this.CmdIn.Text = "In h\x00f3a đơn";
            this.CmdIn.UseVisualStyleBackColor = true;
            this.Label2.AutoSize = true;
            this.Label2.BackColor = Color.Transparent;
            this.Label2.Font = new Font("Microsoft Sans Serif", 10f, FontStyle.Bold, GraphicsUnit.Point, 0);
            point = new Point(12, 9);
            this.Label2.Location = point;
            this.Label2.Name = "Label2";
            size = new Size(0x7e, 0x11);
            this.Label2.Size = size;
            this.Label2.TabIndex = 0;
            this.Label2.Text = "H\x00d3A ĐƠN TỰ IN";
            this.BarCodeHD.CodeType = CodeTypeEnum.Code128;
            point = new Point(12, 0xeb);
            this.BarCodeHD.Location = point;
            this.BarCodeHD.Name = "BarCodeHD";
            size = new Size(0x1b5, 0x2f);
            this.BarCodeHD.Size = size;
            this.BarCodeHD.SizeMode = PictureBoxSizeMode.CenterImage;
            this.BarCodeHD.TabIndex = 7;
            this.BarCodeHD.Text = "12345678901234567890t234567hhhhh";
            this.BarCodeHD.Visible = false;
            SizeF ef = new SizeF(6f, 13f);
            this.AutoScaleDimensions = ef;
            this.AutoScaleMode = AutoScaleMode.Font;
            this.BackgroundImage = ACCOUNTING.My.Resources.Resources.background;
            size = new Size(0x1dc, 0xde);
            this.ClientSize = size;
            this.Controls.Add(this.BarCodeHD);
            this.Controls.Add(this.Label2);
            this.Controls.Add(this.CmdIn);
            this.Controls.Add(this.btnXemTrangIn);
            this.Controls.Add(this.GrpHoaDon);
            this.FormBorderStyle = FormBorderStyle.FixedSingle;
            this.Name = "Frm_InHoaDonTuIn";
            this.StartPosition = FormStartPosition.CenterScreen;
            this.Tag = "BH-0000";
            this.Text = "HOA DON TU IN";
            this.GrpHoaDon.ResumeLayout(false);
            this.GrpHoaDon.PerformLayout();
            this.ResumeLayout(false);
            this.PerformLayout();
        }

        private void Label2_Click(object sender, EventArgs e)
        {
        }

        public byte[] MetafileToByteArray(Metafile meta)
        {
            MemoryStream stream = new MemoryStream();
            using (Bitmap bitmap = new Bitmap(1, 1, PixelFormat.Format32bppArgb))
            {
                using (Graphics graphics = Graphics.FromImage(bitmap))
                {
                    IntPtr hdc = graphics.GetHdc();
                    using (Metafile metafile = new Metafile(stream, hdc))
                    {
                        using (Graphics graphics2 = Graphics.FromImage(metafile))
                        {
                            graphics2.DrawImage(meta, 0, 0, meta.Width, meta.Height);
                            graphics.ReleaseHdc(hdc);
                        }
                    }
                    stream.Close();
                    return stream.GetBuffer();
                }
            }
        }

        private void TxtSoHoaDon_TextChanged(object sender, EventArgs e)
        {
            this.GetBarCode();
        }

        private void TxtSoSeri_LostFocus(object sender, EventArgs e)
        {
            this.CapSoHD(0);
        }

        internal virtual C1.Win.C1BarCode.C1BarCode BarCodeHD
        {
            [DebuggerNonUserCode]
            get
            {
                return this._BarCodeHD;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._BarCodeHD = value;
            }
        }

        internal virtual Button btnXemTrangIn
        {
            [DebuggerNonUserCode]
            get
            {
                return this._btnXemTrangIn;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.btnXemTrangIn_Click);
                if (this._btnXemTrangIn != null)
                {
                    this._btnXemTrangIn.Click -= handler;
                }
                this._btnXemTrangIn = value;
                if (this._btnXemTrangIn != null)
                {
                    this._btnXemTrangIn.Click += handler;
                }
            }
        }

        internal virtual ComboBox CboKiHieu
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CboKiHieu;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CboKiHieu_SelectedIndexChanged);
                if (this._CboKiHieu != null)
                {
                    this._CboKiHieu.SelectedIndexChanged -= handler;
                }
                this._CboKiHieu = value;
                if (this._CboKiHieu != null)
                {
                    this._CboKiHieu.SelectedIndexChanged += handler;
                }
            }
        }

        internal virtual ComboBox CboMau
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CboMau;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CboMau_SelectedIndexChanged);
                if (this._CboMau != null)
                {
                    this._CboMau.SelectedIndexChanged -= handler;
                }
                this._CboMau = value;
                if (this._CboMau != null)
                {
                    this._CboMau.SelectedIndexChanged += handler;
                }
            }
        }

        internal virtual Button CmdDTThue
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CmdDTThue;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CmdDTThue_Click);
                if (this._CmdDTThue != null)
                {
                    this._CmdDTThue.Click -= handler;
                }
                this._CmdDTThue = value;
                if (this._CmdDTThue != null)
                {
                    this._CmdDTThue.Click += handler;
                }
            }
        }

        internal virtual Button CmdIn
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CmdIn;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CmdIn_Click);
                if (this._CmdIn != null)
                {
                    this._CmdIn.Click -= handler;
                }
                this._CmdIn = value;
                if (this._CmdIn != null)
                {
                    this._CmdIn.Click += handler;
                }
            }
        }

        public bool EnabledControl
        {
            get
            {
                return this.mEnabledControl;
            }
            set
            {
                this.mEnabledControl = value;
                this.TxtNgayHoaDon.Enabled = value;
                this.CboMau.Enabled = value;
                this.CboKiHieu.Enabled = value;
                this.TxtSoHoaDon.ReadOnly = !value;
                this.CmdDTThue.Enabled = value;
            }
        }

        internal virtual GroupBox GrpHoaDon
        {
            [DebuggerNonUserCode]
            get
            {
                return this._GrpHoaDon;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._GrpHoaDon = value;
            }
        }

        internal virtual Label Label1
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label1;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label1 = value;
            }
        }

        internal virtual Label Label12
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label12;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label12 = value;
            }
        }

        internal virtual Label Label14
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label14;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label14 = value;
            }
        }

        internal virtual Label Label15
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label15;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label15 = value;
            }
        }

        internal virtual Label Label2
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label2;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.Label2_Click);
                if (this._Label2 != null)
                {
                    this._Label2.Click -= handler;
                }
                this._Label2 = value;
                if (this._Label2 != null)
                {
                    this._Label2.Click += handler;
                }
            }
        }

        internal virtual Label Label30
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label30;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label30 = value;
            }
        }

        internal virtual Label Label8
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label8;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label8 = value;
            }
        }

        internal virtual TextBox txtDiaChiThue
        {
            [DebuggerNonUserCode]
            get
            {
                return this._txtDiaChiThue;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._txtDiaChiThue = value;
            }
        }

        internal virtual TextBox TxtMaSoThue
        {
            [DebuggerNonUserCode]
            get
            {
                return this._TxtMaSoThue;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._TxtMaSoThue = value;
            }
        }

        internal virtual DateTimePicker TxtNgayHoaDon
        {
            [DebuggerNonUserCode]
            get
            {
                return this._TxtNgayHoaDon;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._TxtNgayHoaDon = value;
            }
        }

        internal virtual TextBox TxtSoHoaDon
        {
            [DebuggerNonUserCode]
            get
            {
                return this._TxtSoHoaDon;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.TxtSoHoaDon_TextChanged);
                if (this._TxtSoHoaDon != null)
                {
                    this._TxtSoHoaDon.TextChanged -= handler;
                }
                this._TxtSoHoaDon = value;
                if (this._TxtSoHoaDon != null)
                {
                    this._TxtSoHoaDon.TextChanged += handler;
                }
            }
        }

        internal virtual TextBox TxtTenDoiTuongThue
        {
            [DebuggerNonUserCode]
            get
            {
                return this._TxtTenDoiTuongThue;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._TxtTenDoiTuongThue = value;
            }
        }
    }
}

